package WaiBao;

import java.util.Arrays;

public class YueXiaoXia {
    public static void main(String[] args) {
        String[] name = {"李晨(班长)", "大卫(副班长)", "小李(学习委员)", "王凯(体育委员)", "王祖蓝", "陈赫", "关谷", "唐悠悠", "小虎", "大海", "华晨宇", "吕老板",
                "郭天宇", "李浩宇", " 张虎", "小黑", "小白", "胖胖", "胖墩", "小小怪", "赵四", "张三", "王子文", "杨浩天", "肖央", "刘德华", "张涵予", "倪大红",
                "肖战", "岳晓霞(学生)"};//考生本人: 岳晓霞(学生)
        int[] age = {20, 18, 19, 19, 19, 20, 19, 21, 19, 19, 18, 18, 18, 20, 20, 19, 18, 18, 18, 18, 19, 19, 20, 20, 20, 18, 20, 18, 20, 19};//考生本人年龄:19
        double[] X1 = {78, 84, 94, 90, 99, 69, 78, 89, 80, 89, 91, 87, 85, 89, 65, 68, 99, 99, 96, 88, 92, 91, 95, 65, 75, 74, 94, 74, 78, 95};
        double[] X2 = {77, 85, 99, 96, 98, 77, 78, 69, 90, 90, 90, 77, 66, 95, 65, 65, 76, 99, 66, 98, 72, 71, 95, 86, 75, 88, 84, 94, 80, 96};
        double[] X3 = {74, 96, 80, 95, 79, 99, 98, 69, 80, 80, 73, 97, 85, 95, 65, 68, 69, 96, 96, 93, 92, 81, 65, 95, 76, 84, 73, 91, 69, 94};

        double JJ;//代表每个学生的总分
        double KK;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            JJ = X1[i] + X2[i] + X3[i];
//            KK = (JJ * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + JJ);
//            System.out.println(name[i] + "的平均分为:" + KK);
//        }



        double L1 = 0, P1 = 0;
        double[] qiuhe = new double[30];
//        for (int i = 0; i < 30; i++) {
//            L1 = X1[i] + X2[i] + X3[i];
//            P1= (L1 * 1.0) / 3;
//            qiuhe[i] =P1;
//        }
//
//        for (int i = 0; i < qiuhe.length - 1; i++) {
//            for (int j = 0; j < qiuhe.length - i - 1; j++) {
//                if (qiuhe[j] < qiuhe[j + 1]) {
//                    double tep = qiuhe[j];
//                    qiuhe[j] = qiuhe[j + 1];
//                    qiuhe[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(qiuhe[i]);
//        }


        double N1 = 0, N2 = 0, N3 = 0;//计算每门课的平均分
        double Z1 = 0, Z2 = 0, Z3 = 0;//计算每门课标准差
        double S1 = 0, S2 = 0, S3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i < X1.length; i++) {
            he += X1[i];
        }
        N1 = (he * 1.0) / 30;
        System.out.println("生物化学的班级平均分为:" + N1);
        double Sum = 0;
        for (int i = 0; i < X2.length; i++) {
            Sum += X2[i];
        }
        N2 = (Sum * 1.0) / 30;
        System.out.println("微生物学的班级平均分为:" + N2);
        double sum = 0;
        for (int i = 0; i < X3.length; i++) {
            sum += X3[i];
        }
        N3 = (sum * 1.0) / 30;
        System.out.println("人体组织解剖学的班级平均分为:" + N3);



        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i < X1.length; i++) {
            c1 += (X1[i] - N1) * (X1[i] - N1);
        }
        Z1 = Math.sqrt(c1*1.0/30);
        System.out.println("生物化学的班级标准差为:" + Z1);
        for (int i = 0; i < X2.length; i++) {
            c2 += (X2[i] - N2) * (X2[i] -N2);
        }
       Z2 = Math.sqrt(c2*1.0/30);
        System.out.println("微生物学的班级标准差为:" + Z2);

        for (int i = 0; i < X3.length; i++) {
            c3 += (X3[i] - N3) * (X3[i] - N3);
        }
        Z3 = Math.sqrt(c3*1.0/30);
        System.out.println("人体组织解剖学的班级标准差为:" + Z3);



        Arrays.sort(X1);
        Arrays.sort(X2);
        Arrays.sort(X3);
        S1 = (X1[15] + X2[14]) * 1.0 / 2;
        S2 = (X2[15] + X2[14]) * 1.0 / 2;
        S3 = (X3[15] + X3[14]) * 1.0 / 2;
        System.out.println("生物化学的中位数为:" + S1);
        System.out.println("微生物学的中位数为:" + S2);
        System.out.println("人体组织解剖学的中位数为:" + S3);
    }
}
